package com.example.intercept.filter;

import lombok.extern.slf4j.Slf4j;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * @author: Gzj
 * @data: 2022/7/8
 * @Description: com.example.intercept.filter
 */
@Slf4j
@WebFilter(urlPatterns = "/*")
public class SecondFilter implements Filter {

    /**
     * @param servletRequest
     * @param servletResponse
     * @param filterChain
     * @throws IOException
     * @throws ServletException
     */
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        log.info("[{}]执行{}方法：Before！", this.getClass().getSimpleName(), "doFilter");
        //执行下一个filter
        filterChain.doFilter(servletRequest, servletResponse);
        log.info("[{}]执行{}方法：After！", this.getClass().getSimpleName(), "doFilter");
    }
}
